def testOne(file_name):
    '打印文件中test开头的数据'
    f = open(file_name)
    for v in f:
        if v.startswith('test1'):
            print(v)
    return


# testOne("C:/Users/ZZWang/Desktop/test.txt")
#使用正则表达式方法
import re
def testTwo():
    f = open("C:/Users/ZZWang/Desktop/test.txt")
    pa = re.compile(r'test1')
    for v in f:
        ma=pa.match(v)
        if ma:
            print(ma.string)
testTwo()

def testThree():
    f = open("C:/Users/ZZWang/Desktop/test.txt")
    pa=re.compile("")

